import streamlit as st
import requests

st.title("随机森林新闻分类")
st.write("请输入您的新闻内容")
context = st.text_input("请输入新闻内容")

url = "http://10.254.4.65:5000/rf_predict"

if st.button("预测"):
    try:
        print("context: ",context)
        resp = requests.post(url, json={"data": context})
        st.write(resp.json())
    except Exception as e:
        print(e)
        st.write("预测失败")
    else:
        st.write("预测成功")


